(define-module (luhux services compat)
  #:use-module (gnu services)
  #:use-module (gnu packages)
  #:use-module (gnu packages bash)
  #:use-module (gnu services shepherd)
  #:use-module (guix records)
  #:use-module (guix gexp)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:export (
	    rclocal-service-type
	    rclocal-configuration
	    )
  )

;;
;;
;;  提供一些老发行拥有的功能
;;
;;


(define-record-type* <rclocal-configuration>
  rclocal-configuration make-rclocal-configuration
  rclocal-configuration?
  (script rclocal-configuration-script
	  (default "/etc/rc.local")) ;; string
)


;; 提供类似/etc/rc.local的服务
(define rclocal-service-type
  (shepherd-service-type
   'rclocal
   (lambda (config)
     (define rclocal-script (rclocal-configuration-script config))
     (define rclocal-command (list (file-append bash "/bin/bash")
				   rclocal-script
				   )
       )
     (shepherd-service
      (documentation "Old rc.local compat")
      (provision (list (symbol-append 'rclocal- (string->symbol rclocal-script))))
      (start #~(make-forkexec-constructor '#$rclocal-command))
      (one-shot? #t)
      )
     )
   )
  )
